package com.linkhub.oms.data.sync.api.yunexpress.domain.response;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @Description: 打印标签响应
 * @Author: Jaycle
 * @Date: 2024/06/30 16:41
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class PrintOrderResponse extends YunExpressBaseResponse implements Serializable {

    @JSONField(serialize = false, deserialize = false)
    public boolean success() {
        return SUCCESS_CODE.equals(getCode()) && items != null && !items.isEmpty();
    }

    @JSONField(name = "Item")
    private List<Item> items;

    /**
     * code
     */
    @JSONField(name = "Code")
    private String code;

    /**
     * message
     */
    @JSONField(name = "Message")
    private String message;

    /**
     * requestId
     */
    @JSONField(name = "RequestId")
    private String requestId;

    /**
     * timeStamp
     */
    @JSONField(name = "TimeStamp")
    private String timeStamp;

    /**
     * Item
     */
    @NoArgsConstructor
    @Data
    public static class Item {
        /**
         * url
         */
        @JSONField(name = "Url")
        private String url;

        /**
         * labelType
         */
        @JSONField(name = "LabelType")
        private String labelType;

        /**
         * labelString
         */
        @JSONField(name = "LabelString")
        private String labelString;

        /**
         * orderInfos
         */
        @JSONField(name = "OrderInfos")
        private List<OrderInfo> orderInfos;

        /**
         * OrderInfo
         */
        @NoArgsConstructor
        @Data
        public static class OrderInfo {
            @JSONField(serialize = false, deserialize = false)
            public boolean success() {
                return PRINT_SUCCESS_CODE.equals(getCode());
            }

            /**
             * customerOrderNumber
             */
            @JSONField(name = "CustomerOrderNumber")
            private String customerOrderNumber;

            /**
             * error
             */
            @JSONField(name = "Error")
            private String error;

            /**
             * code
             */
            @JSONField(name = "Code")
            private Integer code;
        }
    }

    /**
     * 自定义类，非云途接口返回，用于组装云途返回信息
     */
    @NoArgsConstructor
    @Data
    public static class DefinePrintResult {

        private String customerOrderNumber;

        private OrderNumberMess orderNumberMess;

        @NoArgsConstructor
        @Data
        public static class OrderNumberMess {
            @JSONField(serialize = false, deserialize = false)
            public boolean success() {
                return PRINT_SUCCESS_CODE.equals(getCode());
            }
            /**
             * error
             */
            private String error;

            /**
             * code
             */
            private Integer code;
            /**
             * url
             */
            private String url;
        }
    }
}
